﻿package  {
	
	import flash.display.MovieClip;
	
	
	public class TestMain extends MovieClip {
		var conn:IMConnection;
		
		public function TestMain() {
			// constructor code
			conn=new IMConnection("121.14.174.205",80);
			conn.addEventListener(IMEvent.LOGINOK,onLoginOK);
			conn.addEventListener(IMEvent.RECVMSG,onRecvMsg);
			conn.addEventListener(IMEvent.RECVSYSMSG,onRecvSysMsg);
			conn.Login("chttest" + int(Math.random()* 100000));
		}
		
		public function onLoginOK(evt:IMEvent):void{
			trace("登录成功");
		}
		
		public function onRecvMsg(evt:IMEvent):void{
			trace(evt.content);
		}
		
		public function onRecvSysMsg(evt:IMEvent):void{
			trace("系统消息：" + evt.content);
		}
	}
	
}
